<?php
require_once("../../resources/commons.php");
require_once("../../data/User.php");
require_once("../../data/Report.php");
require_once("../../data/Item.php");

SessionManager::getInstance()->checkSession();
displayTop("Global report per activity","../../resources/ajaxscripts.php",null);

$l_myUserId=SessionManager::getCurrentLoggedUserId();
$l_user=User::getFromPrimaryKey($l_myUserId);
$l_results=$l_user->getFullTeam();

$l_teamActivities=array();
if(count($l_results)!=0){
	foreach($l_results as $l_teamMember){
		$l_teamActivities=array_merge($l_teamActivities,$l_teamMember->getOpenActivities());
	}
}
$l_teamActivities=array_merge($l_teamActivities,$l_user->getOpenActivities());

if(count($l_teamActivities)!=0){
	$l_teamActivitiesTable=new TableData("ActivitiesTable");
	$l_teamActivitiesTable->addHeader("title","Title");
	$l_teamActivitiesTable->setRecords($l_teamActivities);
	$l_teamActivitiesTable->setZoomArea("ajax_per_activity_dashboard_details.php");
	echo "<h1>The activities managed by your team</h1>";
	displayTable($l_teamActivitiesTable);
}else{
	?>
	<div style="color: white;background-color: red;">No activities</div>
	<?php
}
?>
<center>
<a target="_blank" href="print_per_activity_dashboard.php"><img border="0" src="<?=ROOT_PATH ?>/apps/resources/images/print.png"/></a>
<br/>
<i>Print this report (this will open a new window)</i>
</center> 
<?php
displayBottom();
?>